package com.thb.pay.api.sys;


import com.thb.pay.api.sys.fallback.SysResourceServiceApiFallbackFactory;
import com.thb.pay.api.sys.vo.req.SysResourcePageReq;
import com.thb.pay.api.sys.vo.req.SysResourceReq;
import com.thb.pay.api.sys.vo.resp.SysResourceVo;
import com.thb.pay.core.utils.PageResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>
 * 系统-资源表 前端控制器
 * </p>
 *
 * @author lucky
 * @since 2019-07-21
 */
@FeignClient(value = "pay-service", fallbackFactory = SysResourceServiceApiFallbackFactory.class)
@RequestMapping("/sysResourceApi")
public interface SysResourceServiceApi {

    /**
     * @param pageReq 分页参数
     * @Description 分页-菜单-信息
     * @Author lucky
     * @data 2019/7/21 22:10
     */
    @RequestMapping(value = "/findPage", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    PageResult<SysResourceVo> findPage(@RequestBody SysResourcePageReq pageReq);

    /**
     * @param parentId 菜单parent
     * @Description
     * @Author lucky
     * @data 2019/7/30 23:57
     */
    @RequestMapping(value = "/findListByParentId", method = RequestMethod.GET)
    List<SysResourceVo> findListByParentId(@RequestParam("parentId") Long parentId);

    /**
     * @param systemType 系统类型  1：运营平台, 2：商户平台, 3:代理商系统
     * @Description 获取资源类型下的所有资源信息列表
     * @Author lucky
     * @data 2019/7/30 23:59
     */
    @RequestMapping(value = "/findListBySystemType", method = RequestMethod.GET)
    List<SysResourceVo> findListBySystemType(@RequestParam("systemType") Integer systemType);

    /**
     * @param code 授权路径
     * @Description 获取授权路径对应的资源信息
     * @Author lucky
     * @data 2019/7/30 23:56
     */
    @RequestMapping(value = "/getByPermissionCode", method = RequestMethod.GET)
    SysResourceVo getByPermissionCode(@RequestParam("code") String code);

    /**
     * @param id 资源id
     * @Description 获取资源信息
     * @Author lucky
     * @data 2019/7/30 23:56
     */
    @RequestMapping(value = "/getById", method = RequestMethod.GET)
    SysResourceVo getById(@RequestParam("id") Long id);

    /**
     * @param resourceReq
     * @Description 保存菜单信息
     * @Author lucky
     * @data 2019/7/30 23:58
     */
    @RequestMapping(value = "/save", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    void save(@RequestBody SysResourceReq resourceReq);

    /**
     * @param resourceReq
     * @Description 更新菜单信息
     * @Author lucky
     * @data 2019/7/30 23:58
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    void update(@RequestBody SysResourceReq resourceReq);


    /**
     * @param resourceIds
     * @Description 批量删除菜单资源
     * @Author lucky
     * @data 2019/8/1 23:08
     */
    @RequestMapping(value = "/deleteBatchResourceIds", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    void deleteBatchResourceIds(@RequestBody List<Long> resourceIds);

    /**
     * @param userId
     * @Description 获取用户-菜单-列表
     * @Author lucky
     * @data 2019/8/4 0:01
     */
    @RequestMapping(value = "/findListByUserId", method = RequestMethod.GET)
    List<SysResourceVo> findListByUserId(@RequestParam("userId") Long userId);

    /**
     * @param roleIds
     * @Description 获取角色-菜单-列表
     * @Author lucky
     * @data 2019/9/20
     */
    @RequestMapping(value = "/findListByRoleIds", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    List<SysResourceVo> findListByRoleIds(@RequestBody List<Long> roleIds);

}
